package com.pi.thread;

import java.io.File;
import java.util.List;

import com.pi.ibean.IGPSDataParseBean;
import com.pi.springFactory.SpringFactory;
import com.pi.tools.GDGPSDataParserUtil;
import com.pi.tools.IGPSDataParserUtil;


public class ParseFileTread  implements Runnable{
	private String path;
	
	
    public ParseFileTread(String path){
    	this.path = path;
    }
	
	@Override
	public void run() {
		try {
			IGPSDataParseBean iGPSDataParseBean = (IGPSDataParseBean) SpringFactory.getBean("GPSDataParseBean");
			 System.out.println("此线程开始启动");
			System.out.println(iGPSDataParseBean+"**");
			IGPSDataParserUtil iGpsUtil = new GDGPSDataParserUtil();
			List<String[]> list = null;
			File file = new File(path);
			if(file.exists() && file.list().length >0){
				String[] filenames = file.list();
				for (int i = 0; i < filenames.length; i++) {
					list = iGpsUtil.ParseFile(path + filenames[i]);
					iGPSDataParseBean.saveFileText(filenames[i].replace(".txt",""),list); 
				}
			}
		 System.out.println("此线程结束");
		} catch (Exception e) {
			 e.printStackTrace();
		}
			
			 
	}
	
	
          
}
